package io.dy.controller;

import io.dy.model.Message;
import io.dy.mq.producer.DirectProducer;
import io.dy.mq.producer.FanoutProducer;
import io.dy.mq.producer.TopicProducer;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dmj
 * @date 2024年04月18日 下午4:57
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/io/dy")
public class MqController {

    private final DirectProducer directProducer;

    private final FanoutProducer fanoutProducer;

    private final TopicProducer topicProducer;

    @PostMapping
    public boolean send01(@RequestBody Message message){
        return directProducer.send01(message);
    }


    @PostMapping("/02")
    public boolean send02(@RequestBody Message message){
        return fanoutProducer.send01(message);
    }

    @PostMapping("/03")
    public boolean send03(@RequestBody Message message){
        return topicProducer.send01(message);
    }

    @PostMapping("/04")
    public boolean send04(@RequestBody Message message){
        return topicProducer.send02(message);
    }

    @PostMapping("/05")
    public boolean send05(@RequestBody Message message){
        return topicProducer.send03(message);
    }
}
